package com.video.web.controller.video;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.video.common.annotation.Log;
import com.video.common.core.controller.BaseController;
import com.video.common.core.domain.AjaxResult;
import com.video.common.enums.BusinessType;
import com.video.video.domain.DEdition;
import com.video.video.service.IDEditionService;
import com.video.common.utils.poi.ExcelUtil;
import com.video.common.core.page.TableDataInfo;

/**
 * APP版本控制Controller
 *
 * @author ruoyi
 * @date 2023-03-20
 */
@RestController
@RequestMapping("/video/edition")
public class DEditionController extends BaseController
{
    @Autowired
    private IDEditionService dEditionService;

    /**
     * 查询APP版本控制列表
     */
    @PreAuthorize("@ss.hasPermi('video:edition:list')")
    @GetMapping("/list")
    public TableDataInfo list(DEdition dEdition)
    {
        startPage();
        List<DEdition> list = dEditionService.selectDEditionList(dEdition);
        return getDataTable(list);
    }

    /**
     * 导出APP版本控制列表
     */
    @PreAuthorize("@ss.hasPermi('video:edition:export')")
    @Log(title = "APP版本控制", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DEdition dEdition)
    {
        List<DEdition> list = dEditionService.selectDEditionList(dEdition);
        ExcelUtil<DEdition> util = new ExcelUtil<DEdition>(DEdition.class);
        util.exportExcel(response, list, "APP版本控制数据");
    }

    /**
     * 获取APP版本控制详细信息
     */
    @PreAuthorize("@ss.hasPermi('video:edition:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(dEditionService.selectDEditionById(id));
    }

    /**
     * 新增APP版本控制
     */
    @PreAuthorize("@ss.hasPermi('video:edition:add')")
    @Log(title = "APP版本控制", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DEdition dEdition)
    {
        return toAjax(dEditionService.insertDEdition(dEdition));
    }

    /**
     * 修改APP版本控制
     */
    @PreAuthorize("@ss.hasPermi('video:edition:edit')")
    @Log(title = "APP版本控制", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DEdition dEdition)
    {
        return toAjax(dEditionService.updateDEdition(dEdition));
    }

    /**
     * 删除APP版本控制
     */
    @PreAuthorize("@ss.hasPermi('video:edition:remove')")
    @Log(title = "APP版本控制", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dEditionService.deleteDEditionByIds(ids));
    }
}
